<?php

namespace app\admin\controller;
use tegic\qiniu\Qiniu;

class Upload extends Base
{
	public function qiniuUpload()
	{
		try{
			$qiniu = new Qiniu();
			$result = $qiniu->upload();
			return config('qiniu_url').'/'.$result;
		}catch (Exception $e){
			
			dump($e->getMessage());
		}
		
	}
	//图片上传
    public function upload(){
       $file = request()->file('file');
       $info = $file->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads/images');
       if($info){
            echo $info->getSaveName();
        }else{
            echo $file->getError();
        }
    }
	//图片上传
	public function markdownUpload(){
		$file = request()->file('file');
		$info = $file->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads/images');
		if($info){
			echo '/uploads/images'.DIRECTORY_SEPARATOR.$info->getSaveName();
		}else{
			echo $file->getError();
		}
	}
	//图片上传
    public function uploadfile()
    {
        $file = request()->file('file');
        $info = $file->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads/files');
        if ($info) {
            echo $info->getSaveName();
        } else {
            echo $file->getError();
        }
    }
    //会员头像上传
    public function uploadface(){
       $file = request()->file('file');
       $info = $file->move(env('root_path') . 'public' . DIRECTORY_SEPARATOR . 'uploads/face');
       if($info){
            echo $info->getSaveName();
        }else{
            echo $file->getError();
        }
    }

}